import 'package:flutter/material.dart';
import 'package:flutter_ability/flutter_ability.dart';
import 'package:flutter_ability_example/input/checkbox_widget.dart';
import 'package:flutter_ability_example/input/field_widget.dart';
import 'package:flutter_ability_example/input/radio_widget.dart';
import 'package:flutter_ability_example/utils/color_utils.dart';

class InputPage extends StatefulWidget {
  const InputPage({Key? key}) : super(key: key);

  @override
  State<InputPage> createState() => _InputPageState();
}

class _InputPageState extends State<InputPage> {
  @override
  void initState() {
    super.initState();
    Log.e(tag: "InputPage", "initState()");
  }

  @override
  void dispose() {
    super.dispose();
    Log.i(tag: "InputPage", "dispose()");
    Log.d(tag: "InputPage", "dispose()");
    Log.e(tag: "InputPage", "dispose()");
    Log.w(tag: "InputPage", "dispose()");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("输入"),
      ),
      body: Container(
        padding: const EdgeInsets.only(left: 16, right: 16, top: 20),
        child: buildCenter(context),
      ),
    );
  }

  buildCenter(BuildContext context) {
    return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
      YJButton(
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
            return const CheckWidget();
          }));
        },
        text: "checkbox 复选框",
        color: ColorUtils.getRandomColor(),
        textColor: Colors.white,
      ),
      YJButton(
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
            return const RadioWidget();
          }));
        },
        text: "radio 单选框",
        color: ColorUtils.getRandomColor(),
        textColor: Colors.white,
      ),
      YJButton(
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
            return const FieldWidget();
          }));
        },
        text: "input 输入框",
        color: ColorUtils.getRandomColor(),
        textColor: Colors.white,
      ),
    ]);
  }
}
